package com.ruoyi.web.controller.fs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fs.domain.FsTimeLine;
import com.ruoyi.fs.service.IFsTimeLineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案件时间线Controller
 * 
 * @author hero
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/fs/line")
public class FsTimeLineController extends BaseController
{
    @Autowired
    private IFsTimeLineService fsTimeLineService;

    /**
     * 查询案件时间线列表
     */
    @PreAuthorize("@ss.hasPermi('fs:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsTimeLine fsTimeLine)
    {
        startPage();
        List<FsTimeLine> list = fsTimeLineService.selectFsTimeLineList(fsTimeLine);
        return getDataTable(list);
    }

    /**
     * 导出案件时间线列表
     */
    @PreAuthorize("@ss.hasPermi('fs:line:export')")
    @Log(title = "案件时间线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsTimeLine fsTimeLine)
    {
        List<FsTimeLine> list = fsTimeLineService.selectFsTimeLineList(fsTimeLine);
        ExcelUtil<FsTimeLine> util = new ExcelUtil<FsTimeLine>(FsTimeLine.class);
        util.exportExcel(response, list, "案件时间线数据");
    }

    /**
     * 获取案件时间线详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fsTimeLineService.selectFsTimeLineById(id));
    }

    /**
     * 新增案件时间线
     */
    @PreAuthorize("@ss.hasPermi('fs:line:add')")
    @Log(title = "案件时间线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsTimeLine fsTimeLine)
    {
        return toAjax(fsTimeLineService.insertFsTimeLine(fsTimeLine));
    }

    /**
     * 修改案件时间线
     */
    @PreAuthorize("@ss.hasPermi('fs:line:edit')")
    @Log(title = "案件时间线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsTimeLine fsTimeLine)
    {
        return toAjax(fsTimeLineService.updateFsTimeLine(fsTimeLine));
    }

    /**
     * 删除案件时间线
     */
    @PreAuthorize("@ss.hasPermi('fs:line:remove')")
    @Log(title = "案件时间线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsTimeLineService.deleteFsTimeLineByIds(ids));
    }
}
